package com.example.commen.base.dialoglib.dialog;


import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.blankj.utilcode.util.LogUtils;
import com.example.commen.R;
import com.example.commen.databinding.LayoutDialogLinkagelistsBinding;
import com.hjq.toast.Toaster;

import java.util.Map;


/**
 * 库区/库位
 */
public class linkageListsDialog extends AlertDialog {


    private Map<String, Map<String, String>>[] listMap;
    private boolean outIsHind = true;
    private LayoutDialogLinkagelistsBinding bind;
    private View v;

    private linkageListsDialog(Context context, int theme) {
        super(context, theme);
    }

    public linkageListsDialog(Context context, View v) {
        this(context, true, v);
    }

    public linkageListsDialog(Context context, boolean outIsHind, View v) {
        this(context, R.style.Dialog_NoTitle_Transparency);
        this.outIsHind = outIsHind;
        this.v = v;
    }


    public linkageListsDialog(Context context, View v,Map<String,Map<String,String>>... listMap) {
        this(context, R.style.Dialog_NoTitle_Transparency);
        this.v = v;
        this.listMap = listMap;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        bind = LayoutDialogLinkagelistsBinding.inflate(getLayoutInflater());
//        View view= (View) bind.img.getParent().getParent();
//        view.setBackgroundColor(CommonUtils.getColor(R.color.bg_toum));
        setContentView(bind.getRoot());
        initView();
    }


    private void initView() {

        setCancelable(true);
        this.setCanceledOnTouchOutside(outIsHind);
        //设置其大小
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(lp);
        window.setBackgroundDrawable(getContext().getDrawable(R.drawable.bg_toum));
        window.setGravity(Gravity.BOTTOM);
        window.setWindowAnimations(R.style.IOSAnimStyle);
//        RequestOptions options =new RequestOptions().placeholder(R.drawable.load);
//        Glide.with(CommonUtils.getContext()).load(R.drawable.load).apply(options).into(progress);
        if (outIsHind) {
            bind.conDialogrightParent.setOnClickListener(v -> dismiss());
        }

        bind.btDialogRightYes.setOnClickListener(v1 -> {
            try {


                dismiss();
            }catch (Exception e){
                Toaster.showShort("请选择");
                LogUtils.e(e.getMessage());
            }

        });

        bind.btDialogRightCancel.setOnClickListener(v1 -> dismiss());


    }


    @Override
    public void show() {
        super.show();

    }
}
